package cc.ilzy.mall.coupon.controller;

import cc.ilzy.mall.api.controller.ICouponRecordController;
import cc.ilzy.mall.coupon.service.ICouponRecordService;
import cc.ilzy.mall.model.pojo.User;
import cc.ilzy.mall.model.vo.CouponRecordVO;
import cc.ilzy.mall.utils.ApiResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ilzy
 * @since 2025-07-06
 */
@RestController
public class CouponRecordController implements ICouponRecordController {
    @Autowired
    private ICouponRecordService couponRecordService;

    @GetMapping("/add")
    public ApiResponse<Void> receiveCouponRecord(Long couponId, String category) {
        couponRecordService.addCouponRecord(couponId, category);
        return ApiResponse.success();
    }

    @Override
    public ApiResponse<CouponRecordVO> queryCouponRecordByCouponId(Long couponId) {
        CouponRecordVO vo = couponRecordService.queryCouponRecordByCouponId(couponId);
        return ApiResponse.success(vo);
    }

    @Override
    public ApiResponse<Void> addCouponRecord(Long userId, String username) {
        couponRecordService.addNewCouponRecord(userId, username);
        return ApiResponse.success();
    }


}
